from enum import Enum


# Java状态枚举类
class AppStatus:
    class JAVA_STATUS(Enum):
        """应用状态枚举类"""

        # 正常运行
        RUNNING = "running"
        # 未运行
        DEAD = "dead"
        # 状态错误，需触发错乱恐慌机制
        ERROR = "error"
        # 关键型错误，需要人工干预
        CRITICAL = "critical"

    class STATIC_STATUS(Enum):
        """静态资源状态枚举类"""
        # 正常映射
        MAPPTING = "mapping"
        # 未映射
        UNMAPPED = 'unmapped'
        # 状态错误，需触发错乱恐慌机制
        ERROR = "error"
        # 关键型错误，需要人工干预
        CRITICAL = "critical"
        # nginx配置语法错误
        CANCEL = "cancel"

class Command(Enum):
    """命令枚举类"""

    SEARCH_PID_COMMAND: str = (
        lambda search_path: f"ps -ef | grep {search_path} | grep -v grep | awk '{'print $2'}'"
    )
    BEHAVIOR_COMMAND: dict = {
        "Java": {
            "start": "java -jar {} {} >> {} &",
            "stop": {"safe": "kill -15 {}", "force": "kill -9 {}"},
        }
    }


class Stypes(Enum):
    """应用类型枚举类"""

    JAVA = "Java"
    STATIC = "Static"
